package com.msmall.community.bbs.preparer;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.preparer.ViewPreparer;

import com.msmall.community.ApplicationManager;
import com.msmall.community.bbs.model.Topic;
import com.msmall.community.bbs.service.TopicManager;

/**
 * 首页的今日热帖：10条
 * @author Administrator
 *
 */
public class HotTodayPreparer implements ViewPreparer{

	private static final Log log = LogFactory.getLog(HotTodayPreparer.class);
	
	@SuppressWarnings("unchecked")
	public void execute(TilesRequestContext tilesContext, AttributeContext context) {
		try{
			HttpServletRequest request = (HttpServletRequest) tilesContext.getRequest();
			TopicManager tm = (TopicManager) ApplicationManager.appContext.getBean("topicManager");
			List<Topic> list = tm.hotTopic(10);
			request.setAttribute("hottodaytopiclist", list);
		}catch(Exception e){
			log.debug(e);
		}
	}
}